//
//  FestivalView.swift
//  SimpleCal
//
//  Created by 杜晓祥 on 2021/10/22.
//

import Cocoa

class FestivalView: NSView {
    
    var imageView:NSImageView!
    
    var label:DULabel!
    
    convenience init() {
        self.init(frame: CGRect.zero)
    }

    override init(frame frameRect: NSRect) {
        super.init(frame: frameRect)
        initialize()
    }
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)
        initialize()
    }
    
    private func initialize () {
//        self.mouseDownStyle = getDownStyle()
//        self.mouseEnteredStyle = getEnteredStyle()
//        self.defaultStyle = ViewStyleUtil.dayDefaultStyle()
        imageView = NSImageView()
        imageView.frame = NSRect(x: 5, y: 5, width: 8, height: 8)
        imageView.image = NSImage(named: NSImage.statusAvailableName)
        addSubview(imageView)
        label = DULabel()
        label.frame = NSRect(x: 18, y: 2, width: 87, height: 25)
        label.backgroundColor = NSColor(red: 1, green: 1, blue: 1, alpha: 0.5)
        label.alignment = .left
        label.cell = VerticallyCenteredTextFieldCell()
        label.stringValue = ""
        label.font = NSFont.systemFont(ofSize: 18)
        label.textColor = NSColor(red: 1, green: 1, blue: 1, alpha: 0.9)
        addSubview(label)
    }
    
    override func layout() {
        let h = self.frame.height
        let w = self.frame.width
        imageView.setFrameOrigin(NSPoint(x: 7, y: (h - 8)/2))
        label.setFrameSize(NSSize(width: w - 18, height: h - 4))
    }
    
//    private func getDownStyle() -> ViewStyle {
//        var s = ViewStyle()
//        s.backgroundColor = CGColor(red: 255, green: 255, blue: 255, alpha: 0.4)
//        s.borderColor = nil
//        s.borderWidth = 0
//        s.radius = 8
//        return s
//    }
//
//    private func getEnteredStyle() -> ViewStyle {
//        var s = ViewStyle()
//        s.backgroundColor = CGColor(red: 255, green: 255, blue: 255, alpha: 0.2)
//        s.borderColor = nil
//        s.borderWidth = 0
//        s.radius = 8
//        return s
//    }
    
}
